import {configureStore} from "@reduxjs/toolkit";
import userReducer, {UserStateType} from './userReducer'
import componentsReducer, {ComponentsStateType} from "./componentsReducer";
import pageInfoReducer, {PageInfoType} from "./pageInfoReducer";
import undoable, {excludeAction, StateWithHistory} from "redux-undo";

export type StateType = {
    user: UserStateType
    components: StateWithHistory<ComponentsStateType>
    pageInfo: PageInfoType
}
const store = configureStore({
    reducer: {
        user: userReducer,
        components: undoable(componentsReducer, {
            limit: 20,
            filter: excludeAction([
                'components/resetComponents',
                'components/changeSelectId',
                'components/selectPrevComponent',
                'components/selectNextComponent'
            ])
        }),

        pageInfo: pageInfoReducer
    }
})

export default store